package com.ruoyi.web.controller.statistics.college;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.college.Statistics.ResearchStatistics;
import com.ruoyi.system.service.college.IResearchStatisticsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 科研经费与成果统计数据Controller
 * 
 * @author ruoyi
 * @date 2025-11-24
 */
@RestController
@RequestMapping("/college/researchStatistics")
public class ResearchStatisticsController extends BaseController
{
    @Autowired
    private IResearchStatisticsService researchStatisticsService;

    /**
     * 查询科研经费与成果统计数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ResearchStatistics researchStatistics)
    {
        startPage();
        List<ResearchStatistics> list = researchStatisticsService.selectResearchStatisticsList(researchStatistics);
        return getDataTable(list);
    }

    /**
     * 导出科研经费与成果统计数据列表
     */
    @Log(title = "科研经费与成果统计数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ResearchStatistics researchStatistics)
    {
        List<ResearchStatistics> list = researchStatisticsService.selectResearchStatisticsList(researchStatistics);
        ExcelUtil<ResearchStatistics> util = new ExcelUtil<ResearchStatistics>(ResearchStatistics.class);
        util.exportExcel(response, list, "科研经费与成果统计数据数据");
    }

    /**
     * 获取科研经费与成果统计数据详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(researchStatisticsService.selectResearchStatisticsById(id));
    }

    /**
     * 新增科研经费与成果统计数据
     */
    @Log(title = "科研经费与成果统计数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ResearchStatistics researchStatistics)
    {
        return toAjax(researchStatisticsService.insertResearchStatistics(researchStatistics));
    }

    /**
     * 修改科研经费与成果统计数据
     */
    @Log(title = "科研经费与成果统计数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ResearchStatistics researchStatistics)
    {
        return toAjax(researchStatisticsService.updateResearchStatistics(researchStatistics));
    }

    /**
     * 删除科研经费与成果统计数据
     */
    @Log(title = "科研经费与成果统计数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(researchStatisticsService.deleteResearchStatisticsByIds(ids));
    }
}
